package com.nextbus.ui;

import java.util.HashMap;

import com.nextbus.main.R;

import android.content.Context;
import android.text.Html;
import android.text.Spanned;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * BalloonoverLayView<BusOverlayItem>之中把弹出框的大致框架从xml文件中引入，形成一个视图
 * 然后子类BusPopupView将父类的视图添加到自己的对象中，最后把这个对象添加到mapview里面就形成了弹出框
 * 
 * @author dxt
 *
 */
public class BusPopupView extends BalloonoverLayView<BusOverlayItem>{

	private ImageView favorite;
	private TextView moreInfo;
	private TextView reportProblem;
	private TextView alertsTextView;
    
	private final Spanned moreInfoText;
	private final Spanned reportProblemText;
	private final Spanned noAlertsText;
	
	public BusPopupView(Context context, int balloonBottomOffset,float density) {
		
		super(context,balloonBottomOffset,density);
		FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		params.gravity = Gravity.NO_GRAVITY;
		addView(layout, params);
		
		/**
		 * @author cxd
		 */
		favorite = (ImageView) layoutView.findViewById(R.id.balloon_item_favorite);

		moreInfo = (TextView) layoutView.findViewById(R.id.balloon_item_moreinfo);
		moreInfoText = Html.fromHtml("\n<font color='red'><a href='com.bostonbusmap://moreinfo'>更多信息</a></font>\n");
		moreInfo.setText(moreInfoText);
		
		reportProblem = (TextView) layoutView.findViewById(R.id.balloon_item_report);
		reportProblemText = Html.fromHtml("\n<font color='red'><a href='com.bostonbusmap://reportproblem'>报告<br/>错误</a><font color='red'>\n");
		reportProblem.setText(reportProblemText);
		
		alertsTextView = (TextView) layoutView.findViewById(R.id.balloon_item_alerts);
		noAlertsText = Html.fromHtml("<font color='grey'>No alerts</font>");
		
		
		//现在点击弹出框里面的链接暂时先不干吗，仅仅留着进入口-------------------------------------------
		favorite.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) { 
				System.out.println("favorite");
			}
		});

		moreInfo.setOnClickListener(new OnClickListener() {
			
		@Override
			public void onClick(View v) {
				System.out.println("moreinformation");
			}
		});
		reportProblem.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				System.out.println("problem");
			}
		});
		
		alertsTextView.setOnClickListener(new OnClickListener() {
		
		@Override
			public void onClick(View v) {
				System.out.println("alert");
			}
		});
	}
	
}
